﻿<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                    xmlns:controls="clr-namespace:Controls;assembly=Controls"
                    xmlns:system="clr-namespace:System;assembly=mscorlib"
                    xmlns:themes="clr-namespace:Microsoft.Windows.Themes;assembly=PresentationFramework.Aero"
                    xmlns:xctk="http://schemas.xceed.com/wpf/xaml/toolkit">

    <Style x:Key="MetroFlatButtonStevia" TargetType="Button">
        <Setter Property="Cursor" Value="Hand" />
        <Setter Property="Background" Value="{DynamicResource ColorThemeBrush}" />
        <Setter Property="Foreground" Value="White" />
        <Setter Property="FontSize" Value="14" />
        <Setter Property="Padding" Value="10,10,10,10" />
        <Setter Property="BorderThickness" Value="0" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="Button">
                    <Border x:Name="Border"
                            Margin="3"
                            Background="{TemplateBinding Background}"
                            BorderBrush="{TemplateBinding BorderBrush}"
                            BorderThickness="{TemplateBinding BorderThickness}"
                            CornerRadius="{DynamicResource CornerRadiusSize}">
                        <Grid>
                            <TextBlock Margin="{TemplateBinding Padding}"
                                       HorizontalAlignment="Center"
                                       VerticalAlignment="Center"
                                       Foreground="{TemplateBinding Foreground}"
                                       Text="{TemplateBinding Content}" />
                        </Grid>
                    </Border>
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsPressed" Value="true">
                            <Setter TargetName="Border" Property="Background" Value="{DynamicResource BrushBackgroundOverButtons}" />
                            <Setter Property="Foreground" Value="White" />
                        </Trigger>
                        <Trigger Property="IsMouseOver" Value="True">
                            <Setter Property="Background" Value="{DynamicResource BrushForegroundPressedButtons}" />
                        </Trigger>
                        <Trigger Property="IsDefault" Value="True">
                            <Setter Property="Background" Value="{DynamicResource ColorThemeDarkBrush}" />
                            <Setter Property="BorderBrush" Value="{DynamicResource ColorThemeUltraDarkBrush}" />
                            <Setter Property="BorderThickness" Value="2" />
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
        <Style.Triggers>
            <Trigger Property="IsEnabled" Value="False">
                <Setter Property="Visibility" Value="Collapsed" />
            </Trigger>
        </Style.Triggers>
    </Style>

    <Style x:Key="MetroFlatButtonSteviaWithPicture" TargetType="Button">
        <Setter Property="Cursor" Value="Hand" />
        <Setter Property="Background" Value="{DynamicResource ColorThemeBrush}" />
        <Setter Property="Foreground" Value="White" />
        <Setter Property="FontSize" Value="16" />
        <Setter Property="Padding" Value="10,10,10,10" />
        <Setter Property="BorderThickness" Value="0" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="Button">
                    <Border x:Name="Border"
                            Margin="3"
                            Background="{TemplateBinding Background}"
                            BorderBrush="{TemplateBinding BorderBrush}"
                            BorderThickness="{TemplateBinding BorderThickness}"
                            CornerRadius="{DynamicResource CornerRadiusSize}">
                        <Grid>
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="50" />
                                <ColumnDefinition Width="*" />
                            </Grid.ColumnDefinitions>
                            <ContentPresenter x:Name="Content"
                                              Grid.Column="0"
                                              Margin="10,5,0,5"
                                              HorizontalAlignment="Center"
                                              VerticalAlignment="Center" />
                            <TextBlock Grid.Column="1"
                                       Margin="{TemplateBinding Padding}"
                                       HorizontalAlignment="Center"
                                       VerticalAlignment="Center"
                                       Foreground="{TemplateBinding Foreground}"
                                       Text="{TemplateBinding Tag}" />
                        </Grid>
                    </Border>
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsPressed" Value="true">
                            <Setter TargetName="Border" Property="Background" Value="{DynamicResource BrushBackgroundOverButtons}" />
                            <Setter Property="Foreground" Value="White" />
                        </Trigger>
                        <Trigger Property="IsMouseOver" Value="True">
                            <Setter Property="Background" Value="{DynamicResource BrushForegroundPressedButtons}" />
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
        <Style.Triggers>
            <Trigger Property="IsEnabled" Value="False">
                <Setter Property="Visibility" Value="Collapsed" />
            </Trigger>
        </Style.Triggers>
    </Style>

    <Style x:Key="MetroButtonSteviaWithoutBackground"
           BasedOn="{StaticResource MetroFlatButtonStevia}"
           TargetType="Button">
        <Setter Property="Background" Value="Transparent" />
        <Setter Property="Foreground" Value="{DynamicResource CaptionButtonColor}" />
    </Style>

    <Style BasedOn="{StaticResource MetroFlatButtonStevia}" TargetType="Button">
        <Setter Property="Background" Value="{DynamicResource ColorThemeBrush}" />
        <Setter Property="Foreground" Value="White" />
    </Style>

    <Style x:Key="ButtonWithRedefinedTemplate" TargetType="Button">
        <Setter Property="Cursor" Value="Hand" />
    </Style>
    
    <Style TargetType="xctk:SplitButton">
        <Setter Property="Background" Value="{DynamicResource ColorThemeBrush}" />
        <Setter Property="Foreground" Value="White" />
        <Setter Property="FontSize" Value="14" />
        <Setter Property="Padding" Value="10,10,10,10" />
        <Setter Property="BorderThickness" Value="0" />

        <Setter Property="MaxHeight" Value="50" />
        <Setter Property="IsTabStop" Value="False" />
        <Setter Property="HorizontalContentAlignment" Value="Center" />
        <Setter Property="VerticalContentAlignment" Value="Center" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="xctk:SplitButton">
                    <Grid>
                        <Border Margin="3"
                                Background="{TemplateBinding Background}"
                                BorderBrush="{TemplateBinding BorderBrush}"
                                BorderThickness="{TemplateBinding BorderThickness}"
                                CornerRadius="{DynamicResource CornerRadiusSize}">
                            <Grid>
                                <Grid.ColumnDefinitions>
                                    <ColumnDefinition Width="*" />
                                    <ColumnDefinition Width="1" />
                                    <ColumnDefinition Width="Auto" />
                                </Grid.ColumnDefinitions>
                                <Button x:Name="PART_ActionButton"
                                        Grid.Column="0"
                                        Margin="0"
                                        HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}"
                                        VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}"
                                        Padding="{TemplateBinding Padding}">
                                    <Button.Template>
                                        <ControlTemplate TargetType="Button">
                                            <TextBlock Margin="{TemplateBinding Padding}"
                                                       HorizontalAlignment="Center"
                                                       VerticalAlignment="Center"
                                                       Foreground="{TemplateBinding Foreground}"
                                                       Text="{Binding Path=Content,
                                                                      RelativeSource={RelativeSource Mode=FindAncestor,
                                                                                                     AncestorType=xctk:SplitButton,
                                                                                                     AncestorLevel=1}}" />
                                        </ControlTemplate>
                                    </Button.Template>
                                </Button>
                                <Line Grid.Column="1"
                                      VerticalAlignment="Center"
                                      Stretch="Fill"
                                      Stroke="{TemplateBinding Foreground}"
                                      StrokeThickness="1"
                                      X1="0"
                                      X2="0"
                                      Y1="0.2"
                                      Y2="0.8" />
                                <ToggleButton x:Name="PART_ToggleButton"
                                              Grid.Column="2"
                                              Cursor="Hand"
                                              IsTabStop="False">
                                    <ToggleButton.Template>
                                        <ControlTemplate TargetType="ToggleButton">
                                            <Border x:Name="arrowGlyph"
                                                    Width="20"
                                                    HorizontalAlignment="Stretch"
                                                    VerticalAlignment="Stretch"
                                                    Background="Transparent"
                                                    Cursor="Hand">
                                                <Path HorizontalAlignment="Center"
                                                      VerticalAlignment="Center"
                                                      Data="F1 M 3.860,5.281 L 0.000,0.000 L 8.125,0.000"
                                                      Fill="{Binding Path=Foreground,
                                                                     RelativeSource={RelativeSource Mode=FindAncestor,
                                                                                                    AncestorType=xctk:SplitButton,
                                                                                                    AncestorLevel=1}}" />
                                            </Border>
                                            <ControlTemplate.Triggers>
                                                <Trigger Property="IsMouseOver" Value="True">
                                                    <Setter TargetName="arrowGlyph" Property="Background" Value="{DynamicResource BrushForegroundPressedButtons}" />
                                                </Trigger>
                                            </ControlTemplate.Triggers>
                                        </ControlTemplate>
                                    </ToggleButton.Template>
                                </ToggleButton>
                            </Grid>
                        </Border>

                        <Popup x:Name="PART_Popup"
                               AllowsTransparency="True"
                               Focusable="False"
                               HorizontalOffset="1"
                               IsOpen="{Binding IsChecked,
                                                ElementName=PART_ToggleButton}"
                               Placement="Bottom"
                               PlacementTarget="{Binding ElementName=PART_ActionButton}"
                               StaysOpen="False"
                               VerticalOffset="1">
                            <Border Background="LightGray"
                                    BorderBrush="Gray"
                                    BorderThickness="1">
                                <ContentPresenter x:Name="PART_ContentPresenter"
                                                  Margin="5"
                                                  Content="{TemplateBinding DropDownContent}" />
                            </Border>
                        </Popup>

                    </Grid>
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsMouseOver" Value="True">
                            <Setter Property="Background" Value="{DynamicResource BrushForegroundPressedButtons}" />
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
        <Style.Triggers>
            <Trigger Property="IsEnabled" Value="False">
                <Setter Property="Visibility" Value="Collapsed" />
            </Trigger>
        </Style.Triggers>
    </Style>

    <Style x:Key="BackButtonStyle" TargetType="Button">
        <Setter Property="MinWidth" Value="0" />
        <Setter Property="Width" Value="48" />
        <Setter Property="Height" Value="48" />
        <Setter Property="Margin" Value="36,0,36,36" />
        <Setter Property="VerticalAlignment" Value="Bottom" />
        <Setter Property="FontFamily" Value="Segoe UI Symbol" />
        <Setter Property="FontWeight" Value="Normal" />
        <Setter Property="FontSize" Value="56" />
        <Setter Property="AutomationProperties.AutomationId" Value="BackButton" />
        <Setter Property="AutomationProperties.Name" Value="Back" />
        <Setter Property="AutomationProperties.ItemType" Value="Navigation Button" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="Button">
                    <Grid x:Name="RootGrid">

                        <VisualStateManager.VisualStateGroups>
                            <VisualStateGroup x:Name="CommonStates">
                                <VisualState x:Name="Normal" />
                                <VisualState x:Name="PointerOver">
                                    <Storyboard>
                                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="BackgroundGlyph" Storyboard.TargetProperty="Foreground">
                                            <DiscreteObjectKeyFrame KeyTime="0" Value="{DynamicResource BrushBackgroundOverButtons}" />
                                        </ObjectAnimationUsingKeyFrames>
                                    </Storyboard>
                                </VisualState>
                                <VisualState x:Name="Pressed">
                                    <Storyboard>
                                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="BackgroundGlyph" Storyboard.TargetProperty="Foreground">
                                            <DiscreteObjectKeyFrame KeyTime="0" Value="{DynamicResource BrushForegroundPressedButtons}" />
                                        </ObjectAnimationUsingKeyFrames>
                                        <DoubleAnimation Duration="0"
                                                         Storyboard.TargetName="ArrowGlyph"
                                                         Storyboard.TargetProperty="Opacity"
                                                         To="1" />
                                        <DoubleAnimation Duration="0"
                                                         Storyboard.TargetName="NormalGlyph"
                                                         Storyboard.TargetProperty="Opacity"
                                                         To="0" />
                                    </Storyboard>
                                </VisualState>
                                <VisualState x:Name="Disabled">
                                    <Storyboard>
                                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="RootGrid" Storyboard.TargetProperty="Visibility">
                                            <DiscreteObjectKeyFrame KeyTime="0" Value="Collapsed" />
                                        </ObjectAnimationUsingKeyFrames>
                                    </Storyboard>
                                </VisualState>
                            </VisualStateGroup>
                            <VisualStateGroup x:Name="FocusStates">
                                <VisualState x:Name="Focused">
                                    <Storyboard>
                                        <DoubleAnimation Duration="0"
                                                         Storyboard.TargetName="FocusVisualWhite"
                                                         Storyboard.TargetProperty="Opacity"
                                                         To="1" />
                                        <DoubleAnimation Duration="0"
                                                         Storyboard.TargetName="FocusVisualBlack"
                                                         Storyboard.TargetProperty="Opacity"
                                                         To="1" />
                                    </Storyboard>
                                </VisualState>
                                <VisualState x:Name="Unfocused" />
                                <VisualState x:Name="PointerFocused" />
                            </VisualStateGroup>
                        </VisualStateManager.VisualStateGroups>

                        <Grid Margin="-1,-16,0,0">
                            <TextBlock x:Name="BackgroundGlyph"
                                       Foreground="Transparent"
                                       Text="&#xE0A8;" />
                            <TextBlock x:Name="NormalGlyph" Text="&#xE071;">
                                <TextBlock.Foreground>
                                    <SolidColorBrush Color="{DynamicResource ColorTheme}" />
                                </TextBlock.Foreground>
                            </TextBlock>
                            <TextBlock x:Name="ArrowGlyph"
                                       Foreground="{DynamicResource BrushForegroundPressedButtons}"
                                       Opacity="0"
                                       Text="&#xE0A6;" />
                        </Grid>
                        <Rectangle x:Name="FocusVisualWhite"
                                   IsHitTestVisible="False"
                                   Opacity="0"
                                   StrokeDashArray="1,1"
                                   StrokeDashOffset="1.5"
                                   StrokeEndLineCap="Square">
                            <Rectangle.Stroke>
                                <SolidColorBrush Color="{DynamicResource ColorTheme}" />
                            </Rectangle.Stroke>
                        </Rectangle>
                        <Rectangle x:Name="FocusVisualBlack"
                                   IsHitTestVisible="False"
                                   Opacity="0"
                                   StrokeDashArray="1,1"
                                   StrokeDashOffset="0.5"
                                   StrokeEndLineCap="Square">
                            <Rectangle.Stroke>
                                <SolidColorBrush Color="{DynamicResource ColorTheme}" />
                            </Rectangle.Stroke>
                        </Rectangle>

                    </Grid>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style x:Key="ButtonAppBar" TargetType="Button">
        <Setter Property="Cursor" Value="Hand" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type Button}">
                    <TextBlock x:Name="text"
                               VerticalAlignment="Center"
                               FontSize="12"
                               Foreground="{DynamicResource ColorTextBarreMenuEtatBrush}"
                               Text="{TemplateBinding Content}" />
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsMouseOver" Value="True">
                            <Setter TargetName="text" Property="TextBlock.TextDecorations" Value="Underline" />
                        </Trigger>
                        <Trigger Property="IsPressed" Value="True">
                            <Setter TargetName="text" Property="Foreground" Value="{StaticResource BrushForegroundOverButtons}" />
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
    
</ResourceDictionary>
